//https://www.nowcoder.com/practice/c451a3fd84b64cb19485dad758a55ebe?tpId=13&tqId=23251&ru=%2Fpractice%2F390da4f7a00f44bea7c2f3d19491311b&qru=%2Fta%2Fcoding-interviews%2Fquestion-ranking&sourceUrl=%2Fexam%2Foj%2Fta%3Fpage%3D1%26tpId%3D13%26type%3D13
//滑动窗口解决问题；

#include <iostream>
#include <vector>
using namespace std;

#include <vector>
class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * 
     * @param sum int整型 
     * @return int整型vector<vector<>>
     */
    vector<vector<int> > FindContinuousSequence(int sum) {
        // write code here
        std::vector<std::vector<int>> res_vec{};
        if (sum<3) return res_vec;

        int left = 1;
        int right = 2;
        int mid = (1+sum)/2;
        int cur_sum = left+right;
        std::vector<int> tmp{};
        while(left<mid){
            if (cur_sum == sum) {
                tmp.clear();
                for (int j=left;j<=right;++j) {
                    tmp.emplace_back(j);
                }
                res_vec.emplace_back(tmp);
                right++;
                cur_sum += right;
                continue;
            }else if (cur_sum > sum){
                cur_sum -=left;
                left++;
            }else {
                right++;
                cur_sum += right;
            } 
        }
        return res_vec;
    }
};